package org.lxg.spring.demo;


import org.lxg.spring.config.autobean.AutoBeanConfig;
import org.lxg.spring.pojo.Landlord;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringAopDemo {

    public static void main(String[] args) {

        /**
         * Spring 的的自动装配、
         *  需要在扫描类中 加入 @EnableAspectJAutoProxy
         */
        ApplicationContext contextAutoConfig = new AnnotationConfigApplicationContext(AutoBeanConfig.class);
        Landlord landlord = contextAutoConfig.getBean(Landlord.class);
        landlord.service();

        //异常服务
        landlord.serviceForMoney();

        /**
         *  xml 配置 Spring AOP
          */
        ApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"});
        Landlord landlordXml = context.getBean(Landlord.class);
        landlordXml.service();
    }


}